package com.chenken;

import com.chenken.BinarySearchTree.Visitor;
import com.chenken.printer.BinaryTreeInfo;
import com.chenken.printer.BinaryTrees;

public class Main {

	public static void main(String[] args) {
		Integer data[] = new Integer[] {
			20,25,7,4,9,10,23,6,2,8,1,22,50,30,60,24	
		};
		BinarySearchTree<Integer> bst = new BinarySearchTree<Integer>();
		for(int i = 0;i<data.length;i++) {
			bst.add(data[i]);
		}
		BinaryTrees.println(bst);
//		System.out.println("是否是完全二叉树:"+bst.isComplete());
//		bst.filpBinaryTree();
		bst.preorderTraversal2(new Visitor<Integer>() {
			@Override
			public boolean visit(Integer element) {
				System.out.print(element+",");
				return false;
			}
		});
		System.out.println("");
		bst.preorderTraversal3(new Visitor<Integer>() {
			@Override
			public boolean visit(Integer element) {
				System.out.print(element+",");
				return false;
			}
		});
		System.out.println("");
		bst.inorderTraversal2(new Visitor<Integer>() {
			@Override
			public boolean visit(Integer element) {
				System.out.print(element+",");
				return false;
			}
		});
		System.out.println("");
		bst.postorderTraversal2(new Visitor<Integer>() {
			@Override
			public boolean visit(Integer element) {
				System.out.print(element+",");
				return false;
			}
		});
	}
	
}
